//package com.yi.controller;
//
//import com.yi.model.Book;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
//import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
//import org.springframework.data.elasticsearch.core.query.SearchQuery;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import java.util.List;
//
//import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
//
///**
// * ElasticSearch操作 整合暂时有问题先注释
// * @author YI
// * @date 2018-3-21 12:08:48
// */
//@Controller
//@RequestMapping("/elasticsearch")
//public class ElasticSearchController {
//    @Autowired
//    private ElasticsearchTemplate elasticsearchTemplate;
//
//    /**
//     * 单字符串模糊查询，默认排序。将从所有字段中查找包含传来的word分词后字符串的数据集
//     * http://localhost:9000/elasticsearch/singleWord?word=浣溪沙&size=20
//     * @param word      查询的字符串
//     * @param pageable  分页数据
//     * @return
//     */
//    @RequestMapping("/singleWord")
//    @ResponseBody
//    public List singleTitle(String word, Pageable pageable) {
//        //使用queryStringQuery完成单字符串查询
//        SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(queryStringQuery(word)).withPageable(pageable).build();
//        List<Book> books = elasticsearchTemplate.queryForList(searchQuery, Book.class);
//
//        return books;
//    }
//}
